tl;dr: We used a logistic regression (binomial GLM) to determine the probability of spiders building webs on the loud (1) or quiet (0) side. We scaled and centered mean_leq, condition and age, but back transformed for graphs. Body condition was removed during backward selection. The likelihood of choosing one side over another did not vary by site Leq or age. However, an interaction between Leq and age suggests that the young spiders showed increasing choice for loud with origin Leq but older spiders did not exhibit a choice. Only the loudest site (8B) spiders had a majority choose a particular side (significant difference from 50%).
The first thing we want to do is assess the number of spiders that “chose” (put more silk) on the loud side over the quiet side, and compare it across sites. We can analyze this question in a number of ways. Let’s see a quick breakdown of the data.
Site can be used as categorical or ordinal or replaced by Leq or origin (rural vs urban). We’ve decided to refrain from using site as a categorical variable because there is some logical ordering of the sites (by leq). However, two sites have the same average Leq (6C and 5A) and there is not a reason that we would put one in front of the other. Thus, we think using the Leq is the best metric. We still want to see what individual sites are doing so we can look at each site individually. We will also test origin.
Choice can be also be assessed in a number of ways:
binary data with a binomial distribution (logistic regression) - preferred
proportional data with a beta distribution (not good with only four sites)
count data with a poisson distribution (not good; we have an upper bound)
We will make choice binary with 1’s entered for loud choice and 0 entered for quiet choice. We can include age (days since maturation) and body condition (residuals of lm of log mass and log cephalothorax width). We will scale and center all of the predictor variables first.
Let’s first look at the site average leq. We are interested in the effect of the site average Leq (mean_leq) of the site the spider was collected from on their “choice” of vibratory environment (loud or quiet). For this analysis, we have coded a loud choice as 1 and a quiet choice as 0 (side). Because age (days since maturation) and condition (residuals of lm of log mass and log cephalothorax width) of the spider might affect its choice, we include their interaction with leq. We performed backward selection, which left an interaction between leq and age.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 0.404 | 0.263 | 1.534 | 0.125 |
| mean_leq | 0.306 | 0.276 | 1.109 | 0.268 |
| Age | -0.205 | 0.283 | -0.725 | 0.469 |
| mean_leq:Age | -0.585 | 0.302 | -1.937 | 0.053 |
There is no overall effect of site average Leq on the likelihood of choosing loud or quiet (z = 1.11, df = 65, P = 0.268).
There is no overall effect of age on the likelihood of choosing loud or quiet (z = -0.72, df = 65, P = 0.469).
There is a trend of an interaction between site leq and age; specifically, younger spiders showed increasing preference for loud vibratory environments as origin leq increased, but older spiders show no preference (z = -1.94, df = 65, P = 0.053).
Let’s test each site separately to test the null hypothesis that there is not a majority of spiders choosing one side or the other (50%). Let’s test the models with and without age and choose the best fit model.
The loudest site (Site 8B) differs significantly from 50%, but the others do not. We get the same results with or without age.
Results are similar when we use site as ordinal, but only with the order 5A, 6C, 8A, 8B, not 6C, 5A, 8A, 8B. Results are similar for origin (urban choose loud, rural no choice).
Last, let’s check that there is not a side (left vs right) preference.
Assumption 1: linearity between between predictor and the logit of the outcome
This looks pretty good.
Assumption 2: no outliers
No outliers.
Assumption 3: no multicollinearity
## mean_leq Age mean_leq:Age
## 1.002908 1.044636 1.042685
No highly correlated. Let’s graph the results:
tl:dr: We used a beta regression (with GAM betar) to look at choice on a more continuous scale (i.e., each spider’s proportion of silk in loud). We find similar results to the logistic regression. Spiders also increase the proportion of tunnel silk with increasing leq.
Let’s make the spider’s choice more continuous than a yes/no question. We can look at the proportion of each spider’s silk that was placed on the loud side.
Let’s first look across site leq as we did before. We will use the buildglmmTMB to do backwards selection on a beta regression. If the random effect is removed (it was) we will proceed with the GAM betar with no random effect.
##
## Family: Beta regression(4.217)
## Link function: logit
##
## Formula:
## propl ~ mean_leq * Age
##
## Parametric coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.05324 0.10638 0.500 0.6168
## mean_leq 0.14415 0.10825 1.332 0.1830
## Age -0.04553 0.10792 -0.422 0.6731
## mean_leq:Age -0.25705 0.10829 -2.374 0.0176 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0701 Deviance explained = 13.5%
## -REML = -7.0384 Scale est. = 1 n = 69
There is no overall effect of site average Leq on the proportion of silk on the loud or quiet side (z = 1.33, df = 65, P = 0.183).
There is no overall effect of age on the proportion of silk on the loud or quiet side (z = -0.42, df = 65, P = 0.673).
There is a significant interaction between site leq and age; specifically, younger spiders showed increasing choice for loud vibratory environments as origin leq increased, but older spiders show no preference (z = -2.37, df = 65, P = 0.018).
Let’s test each site for choices that significantly differ from 50%.
Again, only 8B significantly differs from 50% and differs by age.
We get similar results when we include tunnel in the total. When we look at the proportion of silk in the tunnel, there is a significant increase by leq (z = 2.53, df = 67, P = 0.011).
Assumptions
Graph
tl;dr: We used a negative binomial regression to test for differences in total silk use. Again, body condition had no effect. Total silk mass marginally decreased with site average Leq and significantly increased with age (especially for 8B and 6C).
Next we want to know if there are any overall changes in the amount of silk used. Proportional changes can be caused by a number of different changes. Increased proportion of silk on the loud side could mean:
increase in overall silk, more silk in loud without change in quiet
decrease in overall silk, less silk in quiet without change in loud
same silk overall, adds less silk to quiet and more to loud
Let’s look at the total silk mass used (only in loud + quiet). Let’s use a negative binomial since the data is positive, interger with no upper bound, but overdispersion.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 7.031 | 0.053 | 133.544 | 0.000 |
| mean_leq | -0.100 | 0.054 | -1.846 | 0.065 |
| Age | 0.200 | 0.054 | 3.694 | 0.000 |
Only age and origin leq remained in the model.
There is a trend that silk mass decreased with increasing origin leq (z = -1.85, df = 66, P = 0.065).
The amount of silk increased with increasing age (z = 3.69, df = 66, P < 0.001).
Let’s also include tunnel silk in the total.
| Estimate | Std. Error | z value | Pr(>|z|) | |
|---|---|---|---|---|
| (Intercept) | 7.129 | 0.049 | 144.344 | 0 |
| Age | 0.206 | 0.050 | 4.140 | 0 |
Only age remained in the model.
The amount of silk increased with increasing age (z = 4.14, df = 67, P < 0.001).
Let’s look at each site.
Age only effects silk mass (with and without tunnel) in 8B and 6C.
Let’s check the assumptions.
Looks good. Let’s make some graphs!
tl;dr: We used a negative binomial to assess silk mass between loud and quiet sides (side) and it’s interactions with leq, age, and condition. Condition was removed. A three-way interaction between side, leq, and age shows that the amount of loud silk did not change much with increasing leq but younger spiders from louder sites repressed quiet silk use. Older spiders did not show changes in silk use on the quiet side with increasing leq. This is mainly due to site 8B spiders increasing silk use in the quiet side with increasing age.
So we know there is a trend that spiders used less silk when they were from louder sites, but more silk with age. This might suggest that as 8B spiders started adding more silk with age, they probably were putting similar amounts in the loud with increasing amounts in the quiet with age.
Let’s check the stats. We should use a negative binomial because the data appear to be overdispersed. We will similarly test leq with age and condition.
| LR Chisq | Df | Pr(>Chisq) | |
|---|---|---|---|
| side | 0.7446802 | 1 | 0.3881658 |
| mean_leq | 3.4674318 | 1 | 0.0625884 |
| Age | 13.5139748 | 1 | 0.0002368 |
| side:mean_leq | 1.1314963 | 1 | 0.2874564 |
| side:Age | 0.2767920 | 1 | 0.5988116 |
| side:mean_leq:Age | 7.8033280 | 2 | 0.0202083 |
The amount of silk on each side did not interact with leq (Chisq = 1.13, df = 130, P = 0.287) or age (Chisq = 0.28, df = 130, P = 0.599).
There is a significant interaction between side, age, and mean_leq (Chisq = 7.8, df = 130, P = 0.02).
We can also subset by site and look for differences.
We only see effects in 8B where silk increased with age and an interaction revealed that silk mass in loud did not change with age, but quiet silk mass increased with age. Let’s check the assumptions.
There are significant outliers, so let’s see if removing the outliers changes the results.
| LR Chisq | Df | Pr(>Chisq) | |
|---|---|---|---|
| side | 0.0123597 | 1 | 0.9114781 |
| mean_leq | 1.7016574 | 1 | 0.1920714 |
| Age | 16.9429182 | 1 | 0.0000385 |
| side:mean_leq | 2.2379384 | 1 | 0.1346604 |
| side:Age | 0.0023834 | 1 | 0.9610626 |
| side:mean_leq:Age | 8.2148507 | 2 | 0.0164501 |
Same results with or without the outliers (yay!). Let’s graph the results.
tl;dr: We subtracted the proportion of one side from the proportion of the other as a measure of decisiveness and tested it with a beta regression. A trend showed decreasing decisiveness with increasing origin leq. Rural spiders were significantly more decisive.
We can get an idea of how decisive the spiders are by substracting the proportion of silk on one side from the proportion of silk on the other and taking the absolute value. This value ranges from indecisive 0 (50:50 silk each side) to completely decisive 1 (100:0 silk on each side), so we will use a beta regression.
##
## Family: Beta regression(2.72)
## Link function: logit
##
## Formula:
## prop_diff ~ mean_leq
##
## Parametric coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.5262 0.1223 -4.303 1.68e-05 ***
## mean_leq -0.2111 0.1235 -1.709 0.0874 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0253 Deviance explained = 4.86%
## -REML = -6.9852 Scale est. = 1 n = 69
##
## Family: Beta regression(2.797)
## Link function: logit
##
## Formula:
## prop_diff ~ Origin
##
## Parametric coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.2553 0.1715 -1.489 0.1366
## OriginUrban -0.5379 0.2426 -2.217 0.0266 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0525 Deviance explained = 7.97%
## -REML = -8.6061 Scale est. = 1 n = 69
##
## Family: Beta regression(2.897)
## Link function: logit
##
## Formula:
## prop_diff_tunnel ~ mean_leq
##
## Parametric coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.6539 0.1205 -5.427 5.73e-08 ***
## mean_leq -0.2315 0.1219 -1.900 0.0575 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0308 Deviance explained = 5.89%
## -REML = -10.987 Scale est. = 1 n = 69
##
## Family: Beta regression(2.963)
## Link function: logit
##
## Formula:
## prop_diff_tunnel ~ Origin
##
## Parametric coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.3782 0.1688 -2.241 0.0250 *
## OriginUrban -0.5474 0.2395 -2.286 0.0223 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## R-sq.(adj) = 0.0543 Deviance explained = 8.36%
## -REML = -12.421 Scale est. = 1 n = 69
There is a trend that the proportional difference decreases with leq (z = -1.71, df = 67, P = 0.087).
The proportional difference is significantly higher for rural than urban spiders (z = -2.22, df = 67, P = 0.027).
Let’s also see how each site is responding.
5A is most decisive and 8A is least decisive.
choice_spider <- read.csv("data/choice.csv", header = TRUE) %>%
mutate(mean_leq = ifelse(Site == "8B", -55,
ifelse(Site == "8A", -64, -69)),
Origin = as.factor(Origin),
# change origin from loud and quiet ot urban and rural
Origin = fct_recode(Origin, "Urban" = "Loud", "Rural" = "Quiet"),
# put rural first
Origin = fct_relevel(Origin, "Rural", "Urban"))
choice_spider <- full_join(choice_spider, cond, by = "ID") %>%
mutate(condition = as.numeric(condition)) %>%
dplyr::select(ID, Site, Origin, mean_leq, Age, condition, day1_silk_side, day2_silk_side, day3_silk_side, day4_silk_side) %>%
pivot_longer(cols = day1_silk_side:day4_silk_side, values_to = "side_lq", names_to = "day") %>%
mutate(day = fct_recode(day, "1" = "day1_silk_side", "2" = "day2_silk_side", "3" = "day3_silk_side", "4" = "day4_silk_side"),
day = as.numeric(day)) %>%
filter(! is.na(side_lq)) %>%
mutate(side = ifelse(side_lq == "loud", 1, 0))
choice_spider_scaled <- choice_spider %>%
mutate(mean_leq = c(scale(mean_leq)),
Age = c(scale(Age)),
condition = c(scale(condition)),
day = c(scale(day)))
spider <- glmer(side ~ day + Origin + Age + condition + day:Origin + day:Age + day:condition + day:Origin:Age + day:Origin:condition +(1 | ID), data = choice_spider_scaled, family = binomial, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 100000)))
summary(glmer(side ~ day*Origin + (1 | ID), data = choice_spider_scaled, family = binomial, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 100000))))
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: side ~ day * Origin + (1 | ID)
## Data: choice_spider_scaled
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))
##
## AIC BIC logLik deviance df.resid
## 240.1 257.6 -115.0 230.1 241
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7200 -0.2305 0.1825 0.2032 1.7924
##
## Random effects:
## Groups Name Variance Std.Dev.
## ID (Intercept) 18.83 4.339
## Number of obs: 246, groups: ID, 69
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.37954 0.98252 0.386 0.699
## day -0.11995 0.34119 -0.352 0.725
## OriginUrban 0.34292 1.34594 0.255 0.799
## day:OriginUrban 0.09637 0.46544 0.207 0.836
##
## Correlation of Fixed Effects:
## (Intr) day OrgnUr
## day -0.016
## OriginUrban -0.715 0.008
## dy:OrgnUrbn 0.010 -0.733 -0.006
drop1(spider, test = "Chisq")
spider2 <- update(spider, .~. -day:Origin:condition)
drop1(spider2, test = "Chisq")
spider3 <- update(spider2, .~. -day:Origin:Age)
drop1(spider3, test = "Chisq")
spider4 <- update(spider3, .~. -day:Origin)
drop1(spider4, test = "Chisq")
spider5 <- update(spider4, .~. -Origin)
drop1(spider5, test = "Chisq")
spider6 <- update(spider5, .~. -day:Age)
drop1(spider6, test = "Chisq")
spider7 <- update(spider6, .~. -Age)
drop1(spider7, test = "Chisq")
spider8 <- update(spider7, .~. -day:condition)
drop1(spider8, test = "Chisq")
spider9 <- update(spider8, .~. -day)
drop1(spider9, test = "Chisq")
summary(spider)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: side ~ day + Origin + Age + condition + day:Origin + day:Age +
## day:condition + day:Origin:Age + day:Origin:condition + (1 | ID)
## Data: choice_spider_scaled
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))
##
## AIC BIC logLik deviance df.resid
## 245.7 284.3 -111.9 223.7 235
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9526 -0.2193 0.1178 0.1948 1.8824
##
## Random effects:
## Groups Name Variance Std.Dev.
## ID (Intercept) 21.89 4.679
## Number of obs: 246, groups: ID, 69
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.29028 1.08197 0.268 0.788
## day -0.15986 0.37377 -0.428 0.669
## OriginUrban 0.67215 1.51337 0.444 0.657
## Age -0.54685 0.78396 -0.698 0.485
## condition -1.24666 0.95110 -1.311 0.190
## day:OriginUrban 0.08627 0.50532 0.171 0.864
## day:Age 0.16199 0.38590 0.420 0.675
## day:condition 0.02606 0.45330 0.057 0.954
## day:OriginUrban:Age -0.51693 0.50231 -1.029 0.303
## day:OriginUrban:condition 0.43353 0.58919 0.736 0.462
##
## Correlation of Fixed Effects:
## (Intr) day OrgnUr Age condtn dy:OrU day:Ag dy:cnd d:OU:A
## day -0.006
## OriginUrban -0.711 -0.007
## Age -0.145 0.016 0.127
## condition 0.084 0.030 -0.241 -0.210
## dy:OrgnUrbn 0.005 -0.739 0.000 -0.009 -0.006
## day:Age 0.010 -0.295 0.010 -0.042 -0.037 0.218
## day:conditn 0.021 0.271 -0.010 0.010 -0.024 -0.201 -0.275
## dy:OrgnUr:A -0.012 0.228 -0.012 0.042 0.036 -0.131 -0.771 0.211
## dy:OrgnUrb: -0.009 -0.212 0.030 -0.032 -0.023 0.083 0.219 -0.768 -0.334
day1 <- choice_spider %>%
filter(day == 1)
summary(glm(side ~ mean_leq, data = day1, family = binomial))
##
## Call:
## glm(formula = side ~ mean_leq, family = binomial, data = day1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.295 -1.277 1.064 1.081 1.081
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.432141 2.728095 0.158 0.874
## mean_leq 0.002919 0.042776 0.068 0.946
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 78.157 on 56 degrees of freedom
## Residual deviance: 78.152 on 55 degrees of freedom
## AIC: 82.152
##
## Number of Fisher Scoring iterations: 3
summary(glm(side ~ 1, data = day1, family = binomial))
##
## Call:
## glm(formula = side ~ 1, family = binomial, data = day1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.284 -1.284 1.075 1.075 1.075
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.2469 0.2669 0.925 0.355
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 78.157 on 56 degrees of freedom
## Residual deviance: 78.157 on 56 degrees of freedom
## AIC: 80.157
##
## Number of Fisher Scoring iterations: 3
day2 <- choice_spider %>%
filter(day == 2)
summary(glm(side ~ mean_leq, data = day2, family = binomial))
##
## Call:
## glm(formula = side ~ mean_leq, family = binomial, data = day2)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.3812 -1.1551 0.9865 1.1215 1.1999
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.51044 2.63578 0.952 0.341
## mean_leq 0.03715 0.04157 0.894 0.372
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 81.367 on 58 degrees of freedom
## Residual deviance: 80.559 on 57 degrees of freedom
## AIC: 84.559
##
## Number of Fisher Scoring iterations: 4
summary(glm(side ~ 1, data = day2, family = binomial))
##
## Call:
## glm(formula = side ~ 1, family = binomial, data = day2)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.250 -1.250 1.106 1.106 1.106
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.1699 0.2613 0.65 0.516
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 81.367 on 58 degrees of freedom
## Residual deviance: 81.367 on 58 degrees of freedom
## AIC: 83.367
##
## Number of Fisher Scoring iterations: 3
day3 <- choice_spider %>%
filter(day == 3)
summary(glm(side ~ mean_leq, data = day3, family = binomial))
##
## Call:
## glm(formula = side ~ mean_leq, family = binomial, data = day3)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.225 -1.194 1.130 1.161 1.216
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.89082 2.52210 -0.353 0.724
## mean_leq -0.01453 0.03958 -0.367 0.713
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 90.094 on 64 degrees of freedom
## Residual deviance: 89.959 on 63 degrees of freedom
## AIC: 93.959
##
## Number of Fisher Scoring iterations: 3
summary(glm(side ~ 1, data = day3, family = binomial))
##
## Call:
## glm(formula = side ~ 1, family = binomial, data = day3)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.191 -1.191 1.164 1.164 1.164
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.03077 0.24810 0.124 0.901
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 90.094 on 64 degrees of freedom
## Residual deviance: 90.094 on 64 degrees of freedom
## AIC: 92.094
##
## Number of Fisher Scoring iterations: 3
day4 <- choice_spider %>%
filter(day == 4)
summary(glm(side ~ mean_leq, data = day4, family = binomial))
##
## Call:
## glm(formula = side ~ mean_leq, family = binomial, data = day4)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.304 -1.248 1.056 1.109 1.109
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.798843 2.501494 0.319 0.749
## mean_leq 0.009204 0.039309 0.234 0.815
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 89.354 on 64 degrees of freedom
## Residual deviance: 89.299 on 63 degrees of freedom
## AIC: 93.299
##
## Number of Fisher Scoring iterations: 3
summary(glm(side ~ 1, data = day4, family = binomial))
##
## Call:
## glm(formula = side ~ 1, family = binomial, data = day4)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.270 -1.270 1.087 1.087 1.087
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.2162 0.2495 0.867 0.386
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 89.354 on 64 degrees of freedom
## Residual deviance: 89.354 on 64 degrees of freedom
## AIC: 91.354
##
## Number of Fisher Scoring iterations: 3
choice_spider %>%
group_by(day, mean_leq) %>%
count(side_lq) %>%
pivot_wider(values_from = n, names_from = side_lq) %>%
mutate(prop = loud / (loud + quiet)) %>%
arrange(mean_leq)